package de.slothsoft.bookmaker.parse;

import java.util.ArrayList;
import java.util.List;

import de.slothsoft.bookmaker.parse.impl.MangaEdenDescription;
import de.slothsoft.bookmaker.parse.impl.MangaEdenOverviewDescription;
import de.slothsoft.bookmaker.parse.impl.MangaHereDescription;
import de.slothsoft.bookmaker.parse.impl.MangaHereOverviewDescription;

public final class WebsiteDescriptions {

    private static List<WebsiteDescription> descriptions;

    public static synchronized List<WebsiteDescription> createAll() {
        if (descriptions == null) {
            descriptions = new ArrayList<>();
            descriptions.add(new MangaEdenDescription());
            descriptions.add(new MangaEdenOverviewDescription());
            descriptions.add(new MangaHereDescription());
            descriptions.add(new MangaHereOverviewDescription());
        }
        return descriptions;
    }

    public static WebsiteDescription find(String url) {
        for (WebsiteDescription description : createAll()) {
            if (description.isSupported(url)) {
                return description;
            }
        }
        return null;
    }

    private WebsiteDescriptions() {
        // blob blob blip
    }
}
